package network;

import hypeerweb.HyPeerWebSegment;
import hypeerweb.Node;

import java.util.Enumeration;

public class ObjectDBReader {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ObjectDB.setFileLocation("ObjectDatabase.db");
		ObjectDB objectDB = ObjectDB.getSingleton();
		System.out.println(objectDB.getSize());
		objectDB.restore();
		System.out.println(objectDB.getSize());
		objectDB.dump();

		Enumeration<Object> iterator = objectDB.enumeration();
		while (iterator.hasMoreElements()) {
			Object element = iterator.nextElement();
			if (element.getClass() == HyPeerWebSegment.class) {
				HyPeerWebSegment hypeerweb = (HyPeerWebSegment) element;
				System.out.println("hypeerweb size: " + hypeerweb.getSize());
			} else if (element.getClass() == Node.class) {
				Node node = (Node) element;
				System.out.println(node);
			}
		}
	}
}
